package com.resou.reader.bookstore.rank.adapter;

import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.resou.reader.api.entry.ChannelBean;
import java.util.List;

/**
 * Author: 萤火虫
 * E-mail:  Allensuns@163.com
 * Description:
 * CreateTime: 2019-04 -09
 **/
public class FragmentAdapter extends FragmentStatePagerAdapter {
    List<Fragment> mFragmentList;
    List<ChannelBean> mTitleList;

    public FragmentAdapter(FragmentManager fm) {
        super(fm);
    }

    public FragmentAdapter(FragmentManager fm, List<Fragment> mFragmentList) {
        super(fm);
        this.mFragmentList = mFragmentList;
    }

    public FragmentAdapter(FragmentManager fm, List<Fragment> mFragmentList, List<ChannelBean> mTitleList) {
        super(fm);
        this.mFragmentList = mFragmentList;
        this.mTitleList = mTitleList;
    }

    @Override
    public Fragment getItem(int i) {
        return mFragmentList.get(i);
    }

    @Override
    public int getCount() {
        return mFragmentList.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return mTitleList != null ? mTitleList.get(position).getChannelDesc() : super.getPageTitle(position);
    }
}
